#include <iostream>
#include "opencv2/opencv.hpp"
#include "detect.h"

using namespace HeYuDetector;

 int main( )
 {
     //! 1. 图像读取
    cv::VideoCapture cap(0);

    if (!cap.isOpened()) {
         std::cout << "Cannot open the web cam" << std::endl;
         return -1;
    }

    while (true) {
        //! 2. 把图像存入cv::Mat
        cv::Mat imgOriginal;

        if (!cap.read(imgOriginal)) {
             std::cout << "Cannot read a frame from video stream" << std::endl;
             break;
        }

        //! 3. 调用算法
        auto res= Judge(imgOriginal);

        //! 4. 输出结果
        switch(res) {
        case JudeRes::Left :
            std::cout << "turn left" << std::endl;
            break;
        case JudeRes::Right :
            std::cout << "turn right" << std::endl;
            break;
        case JudeRes::Invaild :
            std::cout << "invaild" << std::endl;
            break;
        }

    }

   return 0;

}
